/**
 * @author feng
 * @Date 2021/7/26 8:30
 *    子类对象默认调用父类的构造器
 *    super(...)可以选择调用父类的哪个构造器
 */
public class Test03 {
    public static void main(String[] args) {
        Monkey monkey = new Monkey("金丝猴", 20, "母");
        monkey.eat();

    }
}

class Monkey extends Annimal {

    public Monkey(String name, int age, String sex) {
        super(name, age, sex);    //根据参数匹配调用父类构造器,参数信息传递给父类构造器
    }

    public void eat() {
        System.out.println(getName() + "," + getAge() + "," + getSex());
    }

}


class Annimal {
    private String name;
    private Integer age;
    private String sex;

    public Annimal() {
    }

    public Annimal(String name, Integer age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
}